package com.huawei.admins.platform.gateway.core.component.limiter;

import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

public class PrincipalNameKeyResolver implements  KeyResolver {

    @Override
    public Mono<String> resolve(ServerWebExchange exchange) {
        return exchange.getPrincipal().flatMap(p -> Mono.justOrEmpty(p.getName()));
    }
}
